<template>
  <div class="user">
    <navTop text="设置" />
    <texts textLeft="退出登录" @back="back" class="text" />
  </div>
</template>

<script>
// import navTop from "../../components/navTop";
// import texts from "../../components/text";
export default {
  components: {
    texts: () => import("../../components/text"),
    navTop: () => import("../../components/navTop")
  },
  data() {
    return {};
  },
  methods: {
    back() {
      localStorage.removeItem("token");
      localStorage.removeItem("userId");
      //   console.log(123);
      this.$router.replace({ name: "login" });
    }
  },
  mounted() {
    this.$axios({
      url: "http://liangwei.tech:3000/user/" + localStorage.getItem("userId"),
      method: "get",
      headers: {
        Authorization: "Bearer " + localStorage.getItem("token")
      }
    }).then(res => {
      if (res.data.message == "获取成功") {
        this.datas = res.data.data;
        // console.log(this.datas);
      }
    });
  }
};
</script>

<style lang="less" scoped>
.text {
  // border-radius: 10px;
  // width: 320px;
  // background-color: #fff;
  // margin: 0 18px;
  margin: 0 3px 10px 3px;
  padding: 15px;
  border-radius: 20px 20px;
  border: 2px solid #eee;
}
.user {
  background-color: #fff;
}
</style>